package com.forgotpass;

import java.util.HashMap;

import org.apache.struts2.dispatcher.SessionMap;

import com.commonfunction.CommFunction;
import com.databasefunction.AllDBFunction;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class CheckQuestion extends ActionSupport{
	private String question1,question2,ans1,ans2,user;
	
	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getQuestion1() {
		return question1;
	}

	public void setQuestion1(String question1) {
		this.question1 = question1;
	}

	public String getQuestion2() {
		return question2;
	}

	public void setQuestion2(String question2) {
		this.question2 = question2;
	}

	public String getAns1() {
		return ans1;
	}

	public void setAns1(String ans1) {
		this.ans1 = ans1;
	}

	public String getAns2() {
		return ans2;
	}

	public void setAns2(String ans2) {
		this.ans2 = ans2;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return "success";
	}
	
	@Override
	public void validate() {
		// TODO Auto-generated method stub
		CommFunction commFunction = new CommFunction();
		AllDBFunction allDBFunction = new AllDBFunction();
		HashMap quedata = new HashMap();
		quedata.put("question1", question1);
		quedata.put("ans1", ans1);
		quedata.put("question2", question2);
		quedata.put("ans2", ans2);
		
		HashMap dataDB = allDBFunction.securitytype(user);
		
		if(!dataDB.equals(quedata))
			addActionError("Answers you entered are wrong");
		
	}
}
